<?php
defined('IN_IA') or exit('Access Denied');
global $_GPC, $_W;
$uniacid = $_W['uniacid'];
$setting = $this->baseset($uniacid);
load()->func('tpl');
$pindex = max(1, intval($_GPC['page']));
$psize = 10;
$condition = "";
$condition2 = "";
$condition3 = "";
if (!empty($_GPC['keyword'])) {
	$condition .= " AND CONCAT(`nickname`,`openid`,`orderid`) LIKE '%{$_GPC['keyword']}%'";
}
if (!empty($_GPC['id'])) {
	$condition2 .= " AND CONCAT(`id`) = '{$_GPC['id']}'";
}
if (!empty($_GPC['status'])) {
	$condition3 .= " AND CONCAT(`status`) = '{$_GPC['status']}'";
}
$set = pdo_fetch('SELECT * FROM ' . tablename($this->tableset) . ' WHERE uniacid = :uniacid', array(':uniacid' => $uniacid));
$list = pdo_fetchall("SELECT * FROM " . tablename($this->tableshow) . " WHERE uniacid = '{$_W['uniacid']} ' $condition $condition2 $condition3 ORDER BY displayorder DESC, id DESC LIMIT " . ($pindex - 1) * $psize . ",{$psize}");
if (!empty($list)) {
	foreach ($list as $item => $xfgw) {
		if (!empty($list[$item]['openid'])) {
			load()->model('mc');
			$list[$item]['fansinfo'] = mc_fansinfo($xfgw['openid']);
			$list[$item]['fanid'] = $list[$item]['fansinfo']['fanid'];
			$list[$item]['follow'] = $list[$item]['fansinfo']['follow'];
		}
		$list[$item]['vnum'] = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->tableshow) . " WHERE uniacid = '{$_W['uniacid']}' AND openid = '{$list[$item]['openid']}'");
		$orderinfo = pdo_fetch("SELECT * FROM " . tablename($this->tableorder) . " WHERE uniacid = '{$_W['uniacid']}' AND orderid = '{$list[$item]['orderid']}' LIMIT 1");
		if ($orderinfo) {
			$list[$item]['oredrok'] = 1;
			$list[$item]['orderid2'] = $orderinfo['orderid'];
			$list[$item]['orderfee2'] = $orderinfo['orderfee'];
			$list[$item]['orderstatus2'] = $orderinfo['orderstatus'];
			$list[$item]['shouru_yongjin2'] = $orderinfo['shouru_yongjin'];
			$list[$item]['shouru_bili2'] = $orderinfo['shouru_bili'];
		} else {
			$list[$item]['oredrok'] = 0;
			$list[$item]['orderfee2'] = 0;
			$list[$item]['orderstatus2'] = 0;
			$list[$item]['shouru_yongjin2'] = 0;
			$list[$item]['shouru_bili2'] = 0;
		}
	}
	$total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename($this->tableshow) . " WHERE uniacid = '{$_W['uniacid']}'  $condition");
	$pager = pagination($total, $pindex, $psize);
}
include $this->template('listshow');